﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.CollectionsUI {
    import flash.display.*;
    import org.aswing.*;
    import org.aswing.geom.*;
    import Display.InventoryUI.*;
    import Display.aswingui.*;

    public class CollectableCell extends InventoryCell {

        public static const BOTTOM_GAP_GIFT:int = 30;
        public static const BOTTOM_GAP_WISHLIST:int = 22;
        public static const COLLECTABLE_CELL_GAP:int = 2;

        public function CollectableCell(_arg1:LayoutManager=null){
            super(new SoftBoxLayout(SoftBoxLayout.Y_AXIS, 0, SoftBoxLayout.CENTER));
        }
        override protected function buildCell():void{
            m_alignmentContainer = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            if (this.getCount() > 0){
                m_content = (new (InventoryView.assetDict["collections_inventory_item"])() as DisplayObject);
            } else {
                m_content = (new (InventoryView.assetDict["collections_item_empty"])() as DisplayObject);
            };
            this.setPreferredWidth((m_content.width + (COLLECTABLE_CELL_GAP * 2)));
            this.setMinimumWidth((m_content.width + (COLLECTABLE_CELL_GAP * 2)));
            this.setMaximumWidth((m_content.width + (COLLECTABLE_CELL_GAP * 2)));
            m_bgDec = new MarginBackground(m_content);
            m_alignmentContainer.setBackgroundDecorator(m_bgDec);
            m_alignmentContainer.setPreferredSize(new IntDimension(m_content.width, m_content.height));
            m_alignmentContainer.setMinimumSize(new IntDimension(m_content.width, m_content.height));
            m_alignmentContainer.setMaximumSize(new IntDimension(m_content.width, m_content.height));
            m_overlapPane = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.BOTTOM, -(OVERLAP_AMOUNT));
            m_itemIconPane = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            m_alignmentContainer.append(m_itemIconPane);
            ASwingHelper.prepare(m_alignmentContainer);
            _local1.append(m_alignmentContainer);
            m_overlapPane.append(_local1);
            m_overlapPane.append(this.makeBottomPane());
            ASwingHelper.prepare(m_overlapPane);
            this.append(m_overlapPane);
            this.append(makeNameAndSetPane());
            this.append(ASwingHelper.verticalStrut(13));
            ASwingHelper.prepare(this);
            m_initialized = true;
        }
        override protected function makeBottomPane():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER, BOTTOM_GAP);
            m_useButton = makeUseButton();
            if (m_useButton){
                _local1.append(m_useButton);
            } else {
                _local1.append(ASwingHelper.horizontalStrut(BOTTOM_GAP_WISHLIST));
            };
            _local1.append(ASwingHelper.horizontalStrut(BOTTOM_GAP_GIFT));
            _local1.append(ASwingHelper.horizontalStrut(10));
            var _local2:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            _local2.appendAll(ASwingHelper.verticalStrut(10), makeCountPane());
            ASwingHelper.setEasyBorder(_local2, 0, 0, 0, 5);
            _local1.append(_local2);
            return (_local1);
        }
        override protected function getCount():int{
            return (Global.player.getNumCollectablesOwned(m_item.name));
        }
        override protected function allowUseButton():Boolean{
            return (false);
        }

    }
}//package Display.CollectionsUI 
